/***************************************************
 @Name :        小铭同学
 @Time :        2025-09-03
 @Email :       LiaoMingWJ233@163.com
 @Comment :     扩展板 设备驱动
 @FileName :    hal_mp1a.h
 @Version :     1.0
****************************************************/


#ifndef HAL_MP1A_H
#define HAL_MP1A_H

// #ifdef PLAT_MP1A

#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <linux/input.h>
#include <linux/gpio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>

extern int led_init();
extern int led_on(int nr);
extern int led_off(int nr);
extern int led_all_on();
extern int led_all_off();

extern int beep_init();
extern int beep_on();
extern int beep_off();
extern int set_pwm(int value);
extern void beep_close();

extern int fan_init();
extern int fan_off();
extern int fan_pwm(char *buf);

extern int vibrator_init();
extern int vibrator_on(int strong_magnitude);
extern void vibrator_close();

extern void key_init();
extern int is_Key1_clicked();
extern int is_Key2_clicked();
extern int is_Key3_clicked();

// key1
extern struct gpiohandle_request req1;
extern struct gpiohandle_data data1;
extern int ret1;
extern int fd1;

#define KEY1 "key_gpio_f_9"

// key2
extern struct gpiohandle_request req2;
extern struct gpiohandle_data data2;
extern int ret2;
extern int fd2;
#define KEY2 "key_gpio_f_7"

// key3
extern struct gpiohandle_request req3;
extern struct gpiohandle_data data3;
extern int ret3;
extern int fd3;

#define KEY3 "key_gpio_f_8"

extern int io_init();
extern int get_io_frame();
extern int get_io_infread();
extern int get_io_photoswitch();

// frame
// extern struct io_gpiohandle_request req1;
// extern struct io_gpiohandle_data data1;
extern int io_ret1;
extern int io_fd1;

#define FRAME "flame_gpio_f_5"

// infread
// extern struct io_gpiohandle_request io_req2;
// extern struct io_gpiohandle_data io_data2;
extern int io_ret2;
extern int io_fd2;
#define INFREAD "infrared_gpio_f_12"

// photoswitch
// extern struct io_gpiohandle_request io_req3;
// extern struct io_gpiohandle_data io_data3;
extern int io_ret3;
extern int io_fd3;

#define PHOTOSWITCH "photoswitch_gpio_e_15"

enum lednr
{
    led1 = 1,
    led2,
    led3,
    led4,
    led5,
    led6
};

#define LED_PATH_1 "/sys/class/leds/user1/brightness"
#define LED_PATH_2 "/sys/class/leds/user2/brightness"
#define LED_PATH_3 "/sys/class/leds/led1/brightness"
#define LED_PATH_4 "/sys/class/leds/led2/brightness"
#define LED_PATH_5 "/sys/class/leds/led3/brightness"

#define BEEP_PATH "/dev/input/event0"

#define VIBRATOR "/dev/input/event1"
#define MAX_EFFECTS 15

#define STRONGMAGNITUDE_0 000000
#define STRONGMAGNITUDE_1 0x6551
#define STRONGMAGNITUDE_2 0x9827
#define STRONGMAGNITUDE_3 0xc303
#define STRONGMAGNITUDE_4 0xFFFF
// #endif
#endif
